<template>
  <div class="com-box" ref="box">
    <div class="content">
      <div class="hes"></div>
      <div class="com-ban">
        <p class="com-pone">热门预告片</p>
      </div>
      <div class="swpier">
        <swiper ref="mySwiper" :options="swiperOptions">
          <swiper-slide v-for="ele in arr" :key="ele.mId" class="swp1">
            <div class="swps">
              <img :src="ele.medium" alt class="ims" />
              <div class="swp one">{{ele.title}}</div>
              <div class="swp two">{{ele.year}}</div>
            </div>
          </swiper-slide>
        </swiper>
      </div>
      <div class="com-day">
        <p class="com-new">即将上映</p>
        <swiper ref="Swiper" :options="Options">
          <swiper-slide v-for="(ele,index) in arr" :key="ele.mId" class="swp2">2月{{index+1}}日</swiper-slide>
        </swiper>
      </div>
      <div>
        <ul class="mov-von-box">
          <li class="mov-li" v-for="ele in arr1" :key="ele.mId">
            <div class="mov-img">
              <img :src="ele.small" class="img1" @click="go(ele.mId)" />
              <img src="@/assets/images/movie/play.png" class="mov-paly" />
            </div>
            <div class="con-p">
              <p class="conpone">{{ele.title}}</p>
              <p class="conptwo">
                影火虫评分
                <span class="conspan">{{ele.rating_average}}</span>
              </p>
              <p class="conthree">导演：{{ele.director[0]}}</p>
              <p class="conthree">主演: {{ele.scriptwriter[0]}} {{ele.scriptwriter[1]}}</p>
            </div>
            <div class="btn">预售</div>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
import BScroll from "@better-scroll/core";
export default {
  data() {
    return {
      swiperOptions: {
        slidesPerView: 1.3,
        // spaceBetween: 5,
        centeredSlides: true,
        autoplay: true,
        loop: true,
        pagination: {
          el: ".swiper-pagination",
          clickable: true
        }
        // Some Swiper option/callback...
      },
      Options: {
        slidesPerView: 3,
        spaceBetween: 16,
        loop: true,
        autoplay: true,
        pagination: {
          el: ".swiper-pagination",
          clickable: true
        }
      },

      arr: [],
      arr1: []
    };
  },
  computed: {
    swiper() {
      return this.$refs.mySwiper.$swiper;
    },
    swiper() {
      return this.$refs.Swiper.$swiper;
    }
  },
  created() {
    this.$axios.get("/api/douban/movie/coming_soon").then(res => {
      this.arr = res.data.list;
      this.arr1 = res.data.list;
      console.log(res);
      this.refresh();
    });
  },
  mounted() {
    let wrapper = this.$refs.box;
    this.bScroll = new BScroll(wrapper, {
      click: true
    });
  },
  methods: {
    go(val) {
      // this.$router.push("/movie/point");
      this.$router.push({
        name: "point",
        params: { id: val }
      });
      // this.$store.commit("mid", val);
    },
    refresh() {
      this.$nextTick(() => {
        this.bScroll.refresh();
      });
    }
  }
};
</script>

<style scoped lang="scss">
.com-box {
  width: 100%;
  // margin-top: 44px;
  background: #22262d;
  overflow: hidden;
  height: 99vh;
  .hes {
    width: 100%;
    height: 80px;
  }

  .com-ban {
    margin: 0 auto;
    width: 335px;
    // height: 223px;
    // margin-top: 8.666667rem;
    .com-pone {
      width: 90px;
      height: 18px;
      font-size: 18px;
      font-weight: 500;
      color: rgba(223, 223, 223, 1);
      line-height: 18px;
      text-align: left;
      margin-bottom: 20px;
    }
  }
}
//swiper

.swp1 {
  width: 100%;
  height: 185px;
  transition: 300ms;
  transform: scale(0.8);
  background: lightcoral;
  position: relative;

  img {
    width: 105%;
    object-fit: cover;
    // height: 100%;
  }

  .swp {
    color: #dfdfdf;
    font-size: 16px;
  }
  .one {
    position: absolute;
    top: 85%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99;
  }
  .two {
    position: absolute;
    top: 86%;
    right: 10px;
    z-index: 99;
  }
}
.swiper-slide-active,
.swiper-slide-duplicate-active {
  transform: scale(1);
}
.com-day {
  width: 335px;
  margin: 0 auto;
  margin-top: 26px;
  margin-bottom: 20px;

  .com-new {
    width: 90px;
    height: 18px;
    font-size: 18px;
    font-weight: 500;
    color: rgba(223, 223, 223, 1);
    line-height: 18px;
    text-align: left;
    margin-bottom: 20px;
  }
}
.com-ul {
  display: flex;
  justify-content: space-between;
}

.swp2 {
  width: 82px;
  height: 26px;

  border-radius: 13px;
  font-size: 14px;
  font-weight: 400;
  color: rgba(223, 223, 223, 1);
  line-height: 26px;
  border: 2px solid rgba(151, 151, 151, 1);
  // box-sizing: border-box;
}

body .com-day .swiper-slide-active {
  width: 82px;
  height: 26px;
  background: linear-gradient(
    150deg,
    rgba(242, 91, 134, 1) 0%,
    rgba(241, 172, 94, 1) 100%
  );
  box-shadow: 0px 0px 10px 0px rgba(242, 109, 125, 0.4);
  border-radius: 13px;
}
// 列表
.mov-von-box {
  width: 335px;
  margin: 0 auto;
  height: 1750px;
}

.mov-li {
  width: 335px;
  height: 146px;
  background: rgba(51, 54, 61, 1);
  box-shadow: 0px 0px 4px 2px rgba(0, 0, 0, 0.04);
  border-radius: 6px;
  display: flex;
  margin-bottom: 25px;
  position: relative;

  .mov-img {
    width: 119px;
    height: 100%;
    position: relative;
    .img1 {
      height: 100%;
      width: 100%;
    }

    .mov-paly {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
    }
  }
}

.con-p {
  margin-left: 10px;
}
.conpone {
  font-size: 16px;
  font-weight: 500;
  color: rgba(255, 255, 255, 1);
  line-height: 16px;
  text-align: left;
  margin-top: 15px;
}
.conptwo {
  font-size: 14px;
  color: rgba(255, 255, 255, 1);
  line-height: 14px;
  text-align: left;
  margin-top: 15px;
}
.conspan {
  font-size: 14px;
  color: #fbc34a;
  line-height: 14px;
}
.conthree {
  width: 127px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: rgba(255, 255, 255, 1);
  line-height: 12px;
  text-align: left;
  margin-top: 15px;
}
.btn {
  width: 54px;
  height: 25px;
  background: linear-gradient(
    150deg,
    rgba(98, 75, 163, 1) 0%,
    rgba(203, 68, 152, 1) 100%
  );
  box-shadow: 0px 0px 4px 1px rgba(242, 109, 125, 0.18);
  border-radius: 6px;
  line-height: 25px;
  color: rgba(255, 255, 255, 1);
  font-size: 12px;
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
}
</style>
